#include <amxmodx>
#include <engine>
#include <rpgx>

new upgrade_id;
new g_flameSpr;

public plugin_init()
	register_plugin("FireNade RPGx Upgrade", "2.1", "roflmao456");

public plugin_precache()
	g_flameSpr = precache_model("sprites/flame.spr");

public RPGx_OnPluginReady()
	upgrade_id = RPGx_MakeUpgrade("FireNade", 10, 10, 10);

public RPGx_OnPlayerHurt(victim, attacker, damage, weapon){
	new level = RPGx_GetUpgradeLevel(attacker, upgrade_id);
	if(level && weapon == CSW_HEGRENADE)
		set_task(0.5, "loop_burn", victim, "", 0, "a", level);
	}

public loop_burn(victim){	
	if(!is_user_alive(victim) || entity_get_int(victim, EV_INT_flags)&FL_INWATER){
		remove_task(victim);
		return;
		}
	
	new origin[3];
	get_user_origin(victim, origin);
	
	new rnd = random_num(5, 10);
	
	message_begin(MSG_PVS, SVC_TEMPENTITY, origin);
	write_byte(TE_SPRITE);
	write_coord(origin[0] + random_num(-5, 5));
	write_coord(origin[1] + random_num(-5, 5));
	write_coord(origin[2] + random_num(-10, 10));
	write_short(g_flameSpr);
	write_byte(rnd);
	write_byte(200);
	message_end();
	
	fakedamage(victim, "trigger_hurt", float(rnd), DMG_BURN);
	}